package com.zh.article;

import com.zh.Scene;
import com.zh.creature.Creature;
import com.zh.creature.MonsterTiger;
import com.zh.creature.MonsterWolf;
import com.zh.creature.Person;

/**
 * @description:
 * @author: zhangHang
 * @date: Created in 2020/4/27 10:18
 * @version: 1.0
 * @modified By:
 */
public abstract class Weapon extends Article {
    private int damagePoints;

    public Weapon() {

    }

    public Weapon(String id, String description, int damagePoints) {
        this.setId(id);
        this.setDescription( description);
        this.damagePoints = damagePoints;
    }

    public abstract void useWeapon(Creature enemyCreature, Scene scene);

    public void removeEnemyCreature(Creature enemyCreature, Scene scene){
        if(enemyCreature.getHpValue()<=0){
            if(enemyCreature.equals(scene.getPerson())) {//主角死了，则游戏失败
                System.out.println("You lose!");
                System.exit(0);
            }else if(enemyCreature instanceof MonsterWolf){//狼死
                scene.getPerson().getCurrentRoom().getMonsterWolfSet().remove(enemyCreature.getId());
            }else if(enemyCreature instanceof MonsterTiger){//虎死
                scene.getPerson().getCurrentRoom().getMonsterTigerSet().remove(enemyCreature.getId());
            }else if(enemyCreature instanceof Person){//帮手死
                scene.getPersonSet().remove(enemyCreature.getId());//帮手死了，继续游戏
            }

            if(scene.getGrayWolf().getHpValue()<=0){//Boss死，必须将此If条件句必须放在后面的if语句的前面
                System.out.println("You win!");
                System.exit(0);
            }
            if(scene.judgeSuccess()){
                System.out.println("*******************************");
                System.out.println("you succeed enter the final battle!");
                scene.initFinalBattle();//进入终局之战
            }
        }
    }

    public int getDamagePoints() {
        return damagePoints;
    }

    public void setDamagePoints(int damagePoints) {
        this.damagePoints = damagePoints;
    }
}
